import {getOrderList,supplementData,createDocumentOrder } from '@/api/order/index'
import {isEmptyString} from "@/utils/common";


const order = {
    mutations: {

    },

    actions: {
        //获取订单列表
        GetOrderList({commit}, data) {
            let params = {};
            params.current = data.current
            params.size = data.size
            params.userId = data.userId
            if(!isEmptyString( data.state)) {
                params.state = data.state
            }
            return new Promise((resolve, reject) => {
                getOrderList(params).then(res => {
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        //补充资料
        supplementData({commit}, data) {
            const orderId = data.orderId
            const supplement = data.supplement
            const file = data.file
            return new Promise((resolve, reject) => {
                supplementData({orderId, supplement, file}).then(res => {
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
            },
        //生成文书相关订单
        CreateDocumentOrder({commit}, data) {
            return new Promise((resolve, reject) => {
                createDocumentOrder(data).then(res => {
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
        }
    }
}

export default order